from rich.console import Console
from rich.theme import Theme

# 定义7种颜色主题
custom_theme = Theme({
    "danger": "bold red",
    "warning": "bold yellow",
    "success": "bold green",
    "info": "bold blue",
    "highlight": "bold magenta",
    "special": "bold cyan",
    "critical": "bold white on red"
})

console = Console(theme=custom_theme)

def print_alert(style, message):
    """
    输出带样式的警示信息
    :param style: 样式名称(danger/warning/success/info/highlight/special/critical)
    :param message: 要输出的信息内容
    """
    console.print(f"[{style}]{message}[/]")

# 示例用法
if __name__ == "__main__":
    print_alert("danger", "危险：系统检测到严重错误！")
    print_alert("warning", "警告：磁盘空间不足！")
    print_alert("success", "成功：操作已完成！")
    print_alert("info", "信息：系统运行正常")
    print_alert("highlight", "重点：请检查此配置项")
    print_alert("special", "特殊：检测到异常模式")
    print_alert("critical", "紧急：系统即将崩溃！")